//package cn.edu.xmu.rocketmqdemo.service.mq;
//
//import cn.edu.xmu.rocketmqdemo.model.Log;
//import cn.edu.xmu.rocketmqdemo.util.*;
//import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
//import org.apache.rocketmq.spring.annotation.ConsumeMode;
//import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
//import org.apache.rocketmq.spring.core.RocketMQListener;
//import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Service;
///**
// * 消息消费者
// * @author Ming Qiu
// * @date Created in 2020/11/7 22:47
// **/
//
//@Service//消费者：1.@RocketMQMessageListener注解指定订阅的topic，tag(selectorExpression)，消费模式（consumeMode = 并发消费），指定最多多少个线程消费（consumeThreadMax = 10），所属消费者组  2.实现RocketMQListener<T> 消费者接口 T指定消息的类型
//@RocketMQMessageListener(topic = "log-topic", selectorExpression = "1", consumeMode = ConsumeMode.CONCURRENTLY, consumeThreadMax = 10, consumerGroup = "log-group")
//public class LogConsumerListener implements RocketMQListener<String>, RocketMQPushConsumerLifecycleListener {
//    //RocketMQPushConsumerLifecycleListener生命周期接口  要做不同时期的处理操作才需要实现（prepareStart方法 在listener启动之前打印的方法）
//    private static final Logger logger = LoggerFactory.getLogger(LogConsumerListener.class);
//    @Override
//    public void onMessage(String message) {//泛型里面是String类型所以是 String message
//        Log log = JacksonUtil.toObj(message, Log.class);//json转log对象，输出
//        logger.info("onMessage: got message log =" + log);
//    }
//
//    @Override
//    public void prepareStart(DefaultMQPushConsumer defaultMQPushConsumer) {
//        logger.info("prepareStart: consumergroup =" + defaultMQPushConsumer.getConsumerGroup());
//    }
//}
